package com.tang.algorithm.string;

/**
 * @author tlm
 * @Description
 * @date 2020/7/15 7:24 下午
 */
public class LeetCode392 {

	public static void main(String[] args) {
		String s = "abc";
		String t = "ahbgdc";
		System.out.println(isSubsequence(s, t));
	}

	public static boolean isSubsequence(String s, String t) {
		char[] chars = s.toCharArray();
		int j = -1;
		for (int i = 0; i < chars.length; i++) {
			j = t.indexOf(chars[i], j + 1);
			if (j == -1)
				return false;
		}
		return true;
	}
}
